package com.zhidisoft.system.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="tb_system_function")
public class Function {

	@Id
	@GeneratedValue(generator="system-uuid")
	@GenericGenerator(name="system-uuid",strategy="uuid")
	private String id;
	
	@Column(length=20,nullable=false)
	private String funcName;
	
	@Column(length=255)
	private String funcURL;
	
	@Column(length=50,unique=true,nullable=false)
	private String funcCode;
	
	private String iconClass;
	
	private String iconURL;
	
	@ManyToMany(mappedBy="functions")
	private Set<Role> roles = new HashSet<Role>();
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="parentId")
	private Function parent;
	
	@OneToMany(mappedBy="parent")
	private Set<Function> children = new HashSet<Function>();
	
	/**
	 * 功能类型
	 * 1-菜单功能
	 * 0-按钮功能
	 */
	private Integer funcType = 1;
	
	private Integer status = 1;
	
	private String funcNote;
	
	private Integer sortNum = 0;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="createBy")
	private User createUser;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date updateTime;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="updateBy")
	private User updateUser;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getFuncName() {
		return funcName;
	}

	public void setFuncName(String funcName) {
		this.funcName = funcName;
	}

	public String getFuncURL() {
		return funcURL;
	}

	public void setFuncURL(String funcURL) {
		this.funcURL = funcURL;
	}

	public String getFuncCode() {
		return funcCode;
	}

	public void setFuncCode(String funcCode) {
		this.funcCode = funcCode;
	}

	public String getIconClass() {
		return iconClass;
	}

	public void setIconClass(String iconClass) {
		this.iconClass = iconClass;
	}

	public String getIconURL() {
		return iconURL;
	}

	public void setIconURL(String iconURL) {
		this.iconURL = iconURL;
	}

	public Integer getFuncType() {
		return funcType;
	}

	public void setFuncType(Integer funcType) {
		this.funcType = funcType;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getFuncNote() {
		return funcNote;
	}

	public void setFuncNote(String funcNote) {
		this.funcNote = funcNote;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public User getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(User updateUser) {
		this.updateUser = updateUser;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public Function getParent() {
		return parent;
	}

	public void setParent(Function parent) {
		this.parent = parent;
	}

	public Set<Function> getChildren() {
		return children;
	}

	public void setChildren(Set<Function> children) {
		this.children = children;
	}

	public Integer getSortNum() {
		return sortNum;
	}

	public void setSortNum(Integer sortNum) {
		this.sortNum = sortNum;
	}
	
	
}
